//
//  MVCViewController.swift
//  DemoUI
//
//  Created by 白瑾浩 on 2022/1/7.
//

import UIKit

class MVCViewController: UIViewController {
    var closure:((String)->Void)?
    
    var delegate:MVCViewControllerProtocol? //上一个页码实现了代理
    override func viewDidLoad() {
        super.viewDidLoad()
        self.view.backgroundColor = .white

        // Do any additional setup after loading the view.
        
        let button13 = UIButton(type: UIButton.ButtonType.system)
        button13.frame = CGRect(x: 10, y: 100, width: 150, height: 30)
        button13.setTitle("返回传值到上一页", for: UIControl.State.normal)
        button13.addTarget(self, action: #selector(ret), for: .touchUpInside)
        self.view.addSubview( button13 )
        
    }
    @objc func ret(_ sender:UIButton ){
        
        delegate?.sentData(data: "我来了，我传值了")
        closure!("闭包传值")
        self.dismiss(animated: true, completion: nil)
        
    }
    

    /*
    // MARK: - Navigation
     //在基于故事板的应用程序中，您通常希望在导航之前做一些准备工作
    // In a storyboard-based application, you will often want to do a little preparation before navigation
    override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
        // Get the new view controller using segue.destination.
        // Pass the selected object to the new view controller.
    }
    */

}

protocol MVCViewControllerProtocol{
    func sentData(data:String)
}
